import axios from '../utils/http'
import {setSearchServe,searchServe} from '../utils/searchServe'
const SearchMusicRequest=(info)=>{
    return axios.post("/mgo-music/user/search",info)
}
const WebMusicPlayer=(info)=>{
    var formData = new FormData();
    formData.append("input", info.input);
    formData.append("filter", info.filter);
    formData.append("type", info.type);
    formData.append("page", info.page);
    return axios.post("/music/",formData)
}
const SwtichMusicUrl=(info,isMy=false)=>{
    isMy=searchServe.value;
    if(isMy){
        return SearchMusicRequest(info);
    }else{
        return WebMusicPlayer(info);
    }
}
const selectAllMusic=(currentPage,pageSize,music)=>{
    return axios.post(`/mgo-music/music/selectByPageAndCondition?currentPage=${currentPage}&pageSize=${pageSize}`,music)
}
const addMusic=(music)=>{
    return axios.post("/mgo-music/music/add",music)
}
const updateMusic=(music)=>{
    return axios.post("/mgo-music/music/update",music)
}
const deleteByIds=(ids)=>{
    return axios.post("/mgo-music/music/deleteByIds",ids)
}
const deleteById=(id)=>{
    return axios.post("/mgo-music/music/deleteById",id)
}
export {
    SearchMusicRequest,
    selectAllMusic,
    addMusic,
    updateMusic,
    deleteByIds,
    deleteById,
    WebMusicPlayer,
    SwtichMusicUrl
}